<template>
  <div>
    订单
    <el-table :data="movieList" stripe style="margin-bottom: 20px" border>
      <el-table-column prop="movieName" label="电影名"></el-table-column>
      <el-table-column prop="price" label="价格"></el-table-column>
      <el-table-column prop="payStatus" label="状态"></el-table-column>
      <el-table-column label="操作">
        <template #default="scope">
          <el-button type="primary" @click="buy(scope.row.id)">支付</el-button>
          <el-button type="primary" @click="del(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import axios from "axios";
import {ElMessage} from 'element-plus'

export default {
  data() {
    return {
      loginUser: {},
      movieList: []


    }
  }, methods: {
    findItem() {
      axios.get("/apm/order/cutAll", {params:{userName:this.loginUser.userName}}).then(n => {
        this.movieList = n.data;
      })
    },buy(orderId){
      axios.get("/apm/order/puy",{params:{orderId:orderId}}).then(n=>{
        if(n.data=="ok"){
          ElMessage({
            message: '购买成功',
            type: 'success',
          })
          this.findItem();
        }
      })



    }
    ,del(orderId){
      axios.get("/apm/order/del",{params:{
        orderId:orderId
        }}).then(n=>{
          if(n.data=="ok"){
            ElMessage({
              message: '删除成功',
              type: 'success',
            })
            this.findItem();
          }

      })
    }

  }, created() {
    this.loginUser = JSON.parse(sessionStorage.getItem("loginUser"));
    this.findItem();


  }
}
</script>

<style scoped>

</style>